<div class="layui-fluid">
  <div class="layui-row">
    <div class="layui-col-xs12">
      <div class="layui-card">
        <div class="layui-card-header">
          <a href="#/user/index" title="返回"><i class="layui-icon">&#xe65c;</i></a>编辑用户
        </div>
        <div class="layui-card-body">
          <form class="layui-form" action="">
            <div class="layui-form-item">
              <label class="layui-form-label">用户名</label>
              <div class="layui-input-inline">
                <input type="text" name="username" required lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
              </div>
              <label class="layui-form-label">密码</label>
              <div class="layui-input-inline">
                <input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">手机号</label>
              <div class="layui-input-inline">
                <input type="text" name="mobile" required lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
              </div>
              <label class="layui-form-label">店铺编码</label>
              <div class="layui-input-inline">
                <input type="text" name="shopId" required lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">店铺名称</label>
              <div class="layui-input-inline">
                <input type="text" name="shopName" required lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
              </div>
              <label class="layui-form-label">店铺地址</label>
              <div class="layui-input-inline">
                <input type="text" name="shopAddress" required lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
              </div>
            </div>
            <div class="layui-form-item">
              <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
<script>
  //Demo
  layui.config({
    base: 'js/'
  }).use(['form', 'utils', 'route', 'api', 'axios', 'layer'], function() {
    var form = layui.form;
    var route = layui.route;
    var utils = layui.utils;
    var api = layui.api, axios = layui.axios, layer = layui.layer;
    form.render();
    //监听提交
    form.on('submit(formDemo)', function(data) {
      axios.post(api.user.save, data.field, {
        headers: {
          'X-TOKEN': localStorage.getItem('X-TOKEN')
        }
      }).then(resp => {
        if (resp.data.success === true) {
          layer.msg(resp.data.msg)
          location.href = '#/user/list'
        } else {
          layer.alert(resp.data.msg)
        }
      })
      return false;
    });
  });
</script>
<style scoped>

</style>